 DEFINE INPUT PARAMETER fi-table AS CHARACTER. 

/*
DEFINE VARIABLE fi-table AS CHARACTER.
fi-table = "lbl_mstr".
*/

CASE fi-table :

    WHEN "lbl_mstr" THEN
        RUN lbl_mstr.

    WHEN "lbld_det" THEN
        RUN lbld_det.

   /*zyf add table mnds_det*/
    WHEN "mnds_det" THEN
        RUN mnds_det.

    WHEN "brw_mstr" THEN
        RUN brw_mstr.

    WHEN "brwt_det" THEN
        RUN brwt_det.

    WHEN "brwf_det" THEN
        RUN brwf_det.

    OTHERWISE 
        RETURN.

END CASE.

PROCEDURE lbl_mstr :

FOR EACH db_from.lbl_mstr:

    FIND FIRST db_to.lbl_mstr WHERE db_to.lbl_mstr.lbl_lang = db_from.lbl_mstr.lbl_lang AND 
        db_to.lbl_mstr.lbl_term = db_from.lbl_mstr.lbl_term EXCLUSIVE-LOCK NO-ERROR.

    IF NOT AVAILABLE db_to.lbl_mstr THEN
        CREATE db_to.lbl_mstr.

    ASSIGN
        db_to.lbl_mstr.lbl_lang   = db_from.lbl_mstr.lbl_lang
        db_to.lbl_mstr.lbl_term   = db_from.lbl_mstr.lbl_term
        db_to.lbl_mstr.lbl_long   = db_from.lbl_mstr.lbl_long
        db_to.lbl_mstr.lbl_medium = db_from.lbl_mstr.lbl_medium
        db_to.lbl_mstr.lbl_short  = db_from.lbl_mstr.lbl_short
        db_to.lbl_mstr.lbl_stacked= db_from.lbl_mstr.lbl_stacked
        db_to.lbl_mstr.lbl_desc1 = db_from.lbl_mstr.lbl_desc1
        db_to.lbl_mstr.lbl_desc2 = db_from.lbl_mstr.lbl_desc2
        db_to.lbl_mstr.lbl_mod_userid = db_from.lbl_mstr.lbl_mod_userid
        db_to.lbl_mstr.lbl_mod_date = db_from.lbl_mstr.lbl_mod_date.

END.

END PROCEDURE.

PROCEDURE lbld_det :

    FOR EACH db_from.lbld_det:

        FIND FIRST db_to.lbld_det WHERE db_to.lbld_det.lbld_fieldname = db_from.lbld_det.lbld_fieldname AND
            db_to.lbld_det.lbld_execname = db_from.lbld_det.lbld_execname EXCLUSIVE-LOCK NO-ERROR.

        IF NOT AVAILABLE db_to.lbld_det THEN
            CREATE db_to.lbld_det.

        ASSIGN
            db_to.lbld_det.lbld_term    = db_from.lbld_det.lbld_term
            db_to.lbld_det.lbld_fieldname = db_from.lbld_det.lbld_fieldname
            db_to.lbld_det.lbld_execname  = db_from.lbld_det.lbld_execname
            db_to.lbld_det.lbld_userid  = db_from.lbld_det.lbld_userid
            db_to.lbld_det.lbld_mod_userid  = db_from.lbld_det.lbld_mod_userid
            db_to.lbld_det.lbld_mod_date   = db_from.lbld_det.lbld_mod_date.
	END.
	
END PROCEDURE.

PROCEDURE mnds_det :

FOR EACH db_from.mnds_det:

    FIND FIRST db_to.mnds_det WHERE db_to.mnds_det.mnds_exec = db_from.mnds_det.mnds_exec AND 
        db_to.mnds_det.mnds_exec_sub = db_from.mnds_det.mnds_exec_sub EXCLUSIVE-LOCK NO-ERROR.

    IF NOT AVAILABLE db_to.mnds_det THEN
        CREATE db_to.mnds_det.

    ASSIGN
        db_to.mnds_det.mnds_exec      = db_from.mnds_det.mnds_exec
        db_to.mnds_det.mnds_exec_sub  = db_from.mnds_det.mnds_exec_sub
        db_to.mnds_det.mnds_label     = db_from.mnds_det.mnds_label
        db_to.mnds_det.mnds_userid    = db_from.mnds_det.mnds_userid
        db_to.mnds_det.mnds_mod_date  = db_from.mnds_det.mnds_mod_date
        db_to.mnds_det.mnds_user1     = db_from.mnds_det.mnds_user1
        db_to.mnds_det.mnds_user2     = db_from.mnds_det.mnds_user2
        db_to.mnds_det.mnds__qadc01   = db_from.mnds_det.mnds__qadc01
        db_to.mnds_det.mnds__qadc02   = db_from.mnds_det.mnds__qadc02.
        
END.

END PROCEDURE.

PROCEDURE brw_mstr :

FOR EACH db_from.brw_mstr:

    FIND FIRST db_to.brw_mstr WHERE db_to.brw_mstr.brw_name = db_from.brw_mstr.brw_name EXCLUSIVE-LOCK NO-ERROR.

    IF NOT AVAILABLE db_to.brw_mstr THEN
        CREATE db_to.brw_mstr.

    ASSIGN
        db_to.brw_mstr.brw_name       = db_from.brw_mstr.brw_name
        db_to.brw_mstr.brw_desc       = db_from.brw_mstr.brw_desc
        db_to.brw_mstr.brw_view       = db_from.brw_mstr.brw_view
        db_to.brw_mstr.brw_cansee     = db_from.brw_mstr.brw_cansee
        db_to.brw_mstr.brw_filter     = db_from.brw_mstr.brw_filter
        db_to.brw_mstr.brw_userid     = db_from.brw_mstr.brw_userid
        db_to.brw_mstr.brw_mod_date   = db_from.brw_mstr.brw_mod_date
        db_to.brw_mstr.brw_user1      = db_from.brw_mstr.brw_user1
        db_to.brw_mstr.brw_user2      = db_from.brw_mstr.brw_user2
        db_to.brw_mstr.brw_sort_col   = db_from.brw_mstr.brw_sort_col
        db_to.brw_mstr.brw_col_rtn    = db_from.brw_mstr.brw_col_rtn
        db_to.brw_mstr.brw_pwr_brw    = db_from.brw_mstr.brw_pwr_brw
        db_to.brw_mstr.brw_lu_brw     = db_from.brw_mstr.brw_lu_brw
        db_to.brw_mstr.brw_locked_col = db_from.brw_mstr.brw_locked_col
        db_to.brw_mstr.brw_upd_brw    = db_from.brw_mstr.brw_upd_brw
        db_to.brw_mstr.brw_include    = db_from.brw_mstr.brw_include
        db_to.brw_mstr.brw__qadc01    = db_from.brw_mstr.brw__qadc01
        db_to.brw_mstr.brw__qadc02    = db_from.brw_mstr.brw__qadc02.
        
END.

END PROCEDURE.

PROCEDURE brwt_det :

FOR EACH db_from.brwt_det:

    FIND FIRST db_to.brwt_det WHERE db_to.brwt_det.brw_name = db_from.brwt_det.brw_name AND 
                                    db_to.brwt_det.brwt_seq = db_from.brwt_det.brwt_seq EXCLUSIVE-LOCK NO-ERROR.

    IF NOT AVAILABLE db_to.brwt_det THEN
        CREATE db_to.brwt_det.

    ASSIGN
        db_to.brwt_det.brw_name      = db_from.brwt_det.brw_name
        db_to.brwt_det.brwt_seq       = db_from.brwt_det.brwt_seq
        db_to.brwt_det.brwt_table     = db_from.brwt_det.brwt_table
        db_to.brwt_det.brwt_join      = db_from.brwt_det.brwt_join
        db_to.brwt_det.brwt_where     = db_from.brwt_det.brwt_where
        db_to.brwt_det.brwt_userid    = db_from.brwt_det.brwt_userid
        db_to.brwt_det.brwt_mod_date  = db_from.brwt_det.brwt_mod_date
        db_to.brwt_det.brwt_user1     = db_from.brwt_det.brwt_user1
        db_to.brwt_det.brwt_user2     = db_from.brwt_det.brwt_user2
        db_to.brwt_det.brwt__qadc01   = db_from.brwt_det.brwt__qadc01
        db_to.brwt_det.brwt__qadc02   = db_from.brwt_det.brwt__qadc02.
        
END.

END PROCEDURE.

PROCEDURE brwf_det :

FOR EACH db_from.brwf_det:

    FIND FIRST db_to.brwf_det WHERE db_to.brwf_det.brw_name = db_from.brwf_det.brw_name AND 
                                    db_to.brwf_det.brwf_seq = db_from.brwf_det.brwf_seq EXCLUSIVE-LOCK NO-ERROR.

    IF NOT AVAILABLE db_to.brwf_det THEN
        CREATE db_to.brwf_det.

    ASSIGN
        db_to.brwf_det.brw_name       = db_from.brwf_det.brw_name
        db_to.brwf_det.brwf_seq        = db_from.brwf_det.brwf_seq
        db_to.brwf_det.brwf_field      = db_from.brwf_det.brwf_field
        db_to.brwf_det.brwf_datatype   = db_from.brwf_det.brwf_datatype
        db_to.brwf_det.brwf_format     = db_from.brwf_det.brwf_format
        db_to.brwf_det.brwf_label      = db_from.brwf_det.brwf_label
        db_to.brwf_det.brwf_col_label  = db_from.brwf_det.brwf_col_label
        db_to.brwf_det.brwf_expression = db_from.brwf_det.brwf_expression
        db_to.brwf_det.brwf_table      = db_from.brwf_det.brwf_table
        db_to.brwf_det.brwf_select     = db_from.brwf_det.brwf_select
        db_to.brwf_det.brwf_sort       = db_from.brwf_det.brwf_sort
        db_to.brwf_det.brwf_userid     = db_from.brwf_det.brwf_userid
        db_to.brwf_det.brwf_mod_date   = db_from.brwf_det.brwf_mod_date
        db_to.brwf_det.brwf_user1      = db_from.brwf_det.brwf_user1
        db_to.brwf_det.brwf_user2      = db_from.brwf_det.brwf_user2
        db_to.brwf_det.brwf__qadc01    = db_from.brwf_det.brwf__qadc01
        db_to.brwf_det.brwf__qadc02    = db_from.brwf_det.brwf__qadc02
        db_to.brwf_det.brwf_enable     = db_from.brwf_det.brwf_enable.
END.

END PROCEDURE.
